import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.phoenix.jdbc.PhoenixConnection;
import org.apache.phoenix.schema.MetaDataClient;
import org.apache.phoenix.schema.PColumn;
import org.apache.phoenix.schema.PTable;
import org.junit.Test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class test1 {
    @Test
    public void testDemo1() throws SQLException {
        Configuration conf = HBaseConfiguration.create();
        conf.set("hbase.zookeeper.quorum", "master:2181,node1:2181,node2:2181");
        Connection con =
                DriverManager.getConnection("jdbc:phoenix:master,node1,node2:2181");
        PhoenixConnection phoenixConnection = con.unwrap(PhoenixConnection.class);
        MetaDataClient metaDataClient = new MetaDataClient(phoenixConnection);
        PTable table = metaDataClient.updateCache("", "TEST").getTable();
        Map<String, PColumn> pColumns = new LinkedHashMap<String, PColumn>();
        List<String> columnNames = new ArrayList<String>();
//        columnNames.add("EMPID",name.firstname,name.lastname,company.name,company.address");
        columnNames.add("EMPID");
        columnNames.add("name.firstname");
        columnNames.add("name.lastname");
        for (PColumn pColumn : table.getColumns()) {
            System.out.println(pColumn.getName().getString());
            if (columnNames.contains(pColumn.getName().getString())) {
                pColumns.put(pColumn.getName().getString(), pColumn);
            }
        }
    }
}
